package cn.zgwj.Log.controller;

import cn.zgwj.Log.annotation.LogAnnotation;
import cn.zgwj.Log.domain.LogtableDomain;
import cn.zgwj.Log.query.LogtableQuery;
import cn.zgwj.Log.service.ILogtableService;
import cn.zgwj.basic.util.AjaxResult;
import cn.zgwj.basic.util.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/logs")
public class LogtableController {
    @Autowired
    private ILogtableService logtableService;

    @PostMapping("/list")
    public PageList<LogtableDomain> page(@RequestBody LogtableQuery query){
        return logtableService.queryPage(query);
    }

    @PatchMapping
    @LogAnnotation(module="日志",operater="日志批量删除")
    public AjaxResult batchRemove(@RequestBody List<Long> ids){
        try {
            logtableService.batchRemove(ids);
            return new AjaxResult();
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setSuccess(false).setMessage("删除失败");
        }
    }

}


